package day4;

/**
 * @author oldliu
 * @since 1.0
 */
public class Qie {
    private String name;
    private int health;
    public Qie(){

    }

    public Qie(String name, int health) {
        this.name = name;
        setHealth(health);
//        if(health>100||health<0){
//            System.out.println("这个健康值"+health+"非法");
//            //return;
//            health=20;
//        }
//        this.health = health;
    }

    public void show(){
        System.out.println(name+",健康值:"+health);
    }
    //读写
    public void setName(String n){
         this.name=n;
    }
    public String getName(){
        return name;
    }
    //限制范围在0-100之间
    public void setHealth(int h){
        if(h>100||h<0){
            System.out.println("这个健康值"+h+"非法");
            //return;
            h=20;
        }
        this.health=h;
    }
    public int getHealth(){
        return health;
    }
}
